package com.wizz.trade.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author fyftless
 * 分页结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageVo<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 页数
     */
    private Long pages;

    /**
     * 总记录数
     */
    private Long total;

    /**
     * 数据
     */
    private List<T> data;

    public PageVo(IPage<T> page) {
        this.pages = page.getPages();
        this.total = page.getTotal();
        this.data = page.getRecords();
    }
}
